package br.edu.sistemaacademico.command;

import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;


public class CommandServer {
	public CommandServer() {
		 try {
	            Command aluno = new CommandAluno();
	            Command professor = new CommandProfessor();
	            Command historico = new CommandHistorico();
	            Command matricula = new CommandMatricula();
	            Command servidor = new CommandServidor();
	            Command curso = new CommandCurso();
	            Command disciplina = new CommandDisciplina();
	            Command classe = new CommandClasse();

	            Command turma = new CommandTurma();
	            
	            // para nao usar rmiresgistry, troque a linha abaixo
	            //Naming.rebind( "rmi://localhost:1099/OlaMundoService", o);
	            // pelas duas linhas abaixo
	            
	            Registry registryAluno = LocateRegistry.createRegistry(1099);
	            //Registry registryProfessor = LocateRegistry.createRegistry(1098);
	            
	            registryAluno.rebind("AlunoService", aluno);
	            registryAluno.rebind("ProfessorService", professor);
	            registryAluno.rebind("HistoricoService", historico);
	            registryAluno.rebind("MatriculaService", matricula);
	            registryAluno.rebind("ServidorService", servidor);
	            registryAluno.rebind("CursoService", curso);
	            registryAluno.rebind("DisciplinaService", disciplina);
	            registryAluno.rebind("TurmaService", turma);
	            registryAluno.rebind("ClasseService", classe);
	            
	            System.out.println("Servidor rodando");

	        } catch (Exception e) {
	            System.out.println("Erro:" + e);
	        }
	}
	public static void main(String[] args) {
		CommandServer command = new CommandServer();
	}
}
